chore: Add NetworkPolicy reconciler - #2169
Conversation
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
Introduces operator-managed NetworkPolicy resources for both the Che namespace and user workspace namespaces on OpenShift. A new `spec.networking.networkPolicy.enabled` field controls the feature (disabled by default). When enabled, the operator creates fine-grained ingress and egress policies: Che namespace policies: - allow-from-same-namespace: Che-to-Che pod traffic - allow-from-workspaces-namespaces-to-openvsx-registry - allow-from-workspaces-namespaces-to-plugin-registry - allow-from-openshift-ingress - allow-from-openshift-monitoring - allow-from-operator: operator pod to Che components - allow-to-everywhere: all egress from Che pods User workspace namespace policies: - allow-from-<che-namespace>: ingress from Che namespace - allow-from-same-namespace: intra-namespace traffic - allow-from-devworkspace-operator: DWO to workspace pods - allow-from-openshift-monitoring - allow-from-openshift-ingress - allow-to-everywhere: all egress from workspace pods Also refactors DwoNamespaceReconciler into a utility function and extends the cache selector to watch DevWorkspace operator pods. Assisted-by: Claude Opus 4.6 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
|
I tested these changes and can confirm it works as expected. ✔️ After installing Eclipse Che based on these changes, and enabling Network Policies I could see NetworkPolicies getting created: After creating a workspace, I could see NetworkPolicies in user namespace: After disabling Network Policies I could see created NetworkPolicies getting cleaned up: |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: rohanKanojia, tolusha The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi! I'm che-ai-assistant — I help with your pull requests. I check for new comments every 10m0s, so there may be a short delay before I respond. Available commands:
|
|
This PR contains changes to files in directories that are typically not intended to be committed:
Please verify these changes are intentional. |
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
|
New changes are detected. LGTM label has been removed. |
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
|
/test v19-devworkspace-happy-path |


What does this PR do?
Introduces operator-managed NetworkPolicy resources for both the Che namespace and user workspace namespaces on OpenShift clusters.
A new
spec.networking.networkPolicy.enabledfield controls the feature (disabled by default). When enabled, the operator creates fine-grained ingress and egress NetworkPolicy resources to restrict network traffic to only the flows required by Che components and workspaces.Che namespace policies:
allow-from-same-namespace— allows ingress traffic between Che pods in the same namespaceallow-from-workspaces— allows ingress traffic from user workspace namespacesallow-from-openshift-ingress— allows ingress traffic from the OpenShift ingress namespaceallow-from-openshift-monitoring— allows ingress traffic from the OpenShift monitoring namespaceallow-from-<flavor>-operator— allows ingress traffic from the operator pod to Che componentsallow-all-egress— allows all egress traffic from Che podsUser workspace namespace policies:
allow-from-<che-namespace>— allows ingress traffic from Che namespace podsallow-from-same-namespace— allows ingress traffic between pods in the same namespaceallow-from-devworkspace-operator— allows ingress traffic from the DevWorkspace operatorallow-from-openshift-monitoring— allows ingress traffic from the OpenShift monitoring namespaceallow-from-openshift-ingress— allows ingress traffic from the OpenShift ingress namespaceallow-all-egress— allows all egress traffic from Che podsAdditional changes:
DwoNamespaceReconcilerinto a utility functionGetDevWorkspaceOperatorNamespaceNetworkPolicydiff option,DeleteIgnoreNotFoundk8s client method, and related constantsScreenshot/screencast of this PR
N/A — infrastructure change, no UI impact.
What issues does this PR fix or reference?
CRW-10821
How to test this PR?
OpenShift
or
kubectl patch checluster eclipse-che -n eclipse-che --type merge -p '{"spec":{"networking":{"networkPolicy":{"enabled":true}}}}'Expected: 6 NetworkPolicy resources (allow-from-same-namespace, allow-from-workspaces, allow-from-openshift-ingress, allow-from-openshift-monitoring, allow-from-che-operator, allow-all-egress).
Expected: 6 NetworkPolicy resources (allow-from-eclipse-che, allow-from-same-namespace, allow-from-devworkspace-operator, allow-from-openshift-monitoring, allow-from-openshift-ingress, allow-all-egress).
Expected: all Che-managed NetworkPolicy resources are deleted.
Common Test Scenarios
PR Checklist
As the author of this Pull Request I made sure that:
Reviewers
Reviewers, please comment how you tested the PR when approving it.